using System.Linq;
using NUnit.Framework;

namespace Solver
{
	/// <summary>
	/// What is the sum of the digits of the number 2^1000?
	/// </summary>
	public class Problem016 : SelfChecker, IProblem
	{
		public int Id
		{
			get { return 16; }
		}

		public string Solve()
		{
			return Solve(1000).ToString();
		}

		[Test]
		public override void Check()
		{
			Assert.AreEqual(26, Solve(15));
			Assert.AreEqual(1366, Solve(1000));
		}

		private static int Solve(int param)
		{
			var sum = new Number(1);
			for (int i = 0; i < param; i++)
				sum = sum.Add(sum);
			return sum.ToString().ToCharArray().Select(c => c - '0').Sum();
		}
	}
}